package com.senmall.goodsweb;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @Author: senrian
 * Time: 2019-08-09 14:12
 * Feature:
 */
@SpringBootApplication
@EnableDiscoveryClient
public class LyUploadService {
    public static void main(String[] args) {
        SpringApplication.run(LyUploadService.class, args);
    }
}

class Test{
    public static void main(String[] args) {
        List<String> wordDict = new ArrayList<>();
        wordDict.add("aaaa");
        wordDict.add("aaa");
        System.out.println(wordBreak("aaaaaaa",wordDict));
    }

    public static boolean wordBreak(String s, List<String> wordDict) {
        Set<String> set = new HashSet<>(wordDict);
        StringBuilder sb = new StringBuilder();
        boolean flag = false;
        for(int i = 0; i < s.length(); i++){
            sb.append(s.charAt(i));
            if(set.contains(sb.toString())){
                flag = true;
                sb = new StringBuilder();
            }else{
                flag = false;
            }
        }
        return flag;

    }

}
